package com.kyh.vo;

import java.util.HashMap;

import com.kyh.properties.ErrMsg;

public class M extends HashMap<String, Object> {
    private static final long serialVersionUID = 1L;
    
    public static int STATE_SUC = 1;
    
    public static int STATE_ERR = 0;
    
    public static int STATE_UN_CONFIRM = 2; // 未知待确认
    
    public int getState() {
    	return Integer.parseInt(this.get("state").toString());
    }
    public String getMessage() {
    	return this.get("message").toString();
    }

    public static M err() {
        M r = new M();
        r.put("state", 0);
        r.put("message", ErrMsg.get(300));
        return r;
    }

    public static M err(String message) {
        M r = new M();
        r.put("state", 0);
        r.put("message", message);
        return r;
    }
    
    public static M suc() {
        M r = new M();
        r.put("state", 1);
        r.put("message", ErrMsg.get(200));
        return r;
    }

    public static M suc(String message) {
        M r = new M();
        r.put("state", 1);
        r.put("message", message);
        return r;
    }

    public static M suc(Object object) {
        M r = new M();
        r.put("state", 1);
        r.put("message", ErrMsg.get(200));
        r.put("data", object);
        return r;
    }

    public static M suc(String message, Object object) {
        M r = new M();
        r.put("state", 1);
        r.put("message", message);
        r.put("data", object);
        return r;
    }

    public static M unConfirm(String message) {
        M r = new M();
        r.put("state", 2);
        r.put("message", message);
        return r;
    }

    public static M unConfirm(String message, Object object) {
        M r = new M();
        r.put("state", 1);
        r.put("message", message);
        r.put("data", object);
        return r;
    }

    @Override
    public M put(String key, Object value) {
        super.put(key, value);
        return this;
    }
}
